package gui;


import java.util.List;

import javax.swing.JLabel;
import javax.swing.JComboBox;

import server.ejb.beans.Parkposition;;

@SuppressWarnings("serial")
public class MaskParkpositionen extends Masks {

	private JComboBox<Integer> cbxParkposition;
	
	private JLabel lblParkposition;
	
	private List<Parkposition> ppListe;
	
	/**
	 * Create the panel.
	 */
	public MaskParkpositionen() 
	{
		super();
		
		lblParkposition = new JLabel("Parkposition:");
		lblParkposition.setBounds(37, 17, 79, 14);
		add(lblParkposition);
		
		cbxParkposition = new JComboBox<Integer>();
		cbxParkposition.setBounds(124, 14, 248, 20);
		add(cbxParkposition);	
	}

	@Override
	public boolean checkInhalt() {
		if (cbxParkposition.getSelectedIndex() == -1){
			return false;
		}
		return true;
	}
	
	public void setParkpositionenListe(List<Parkposition> ppListe) {
		this.ppListe = ppListe;
		cbxParkposition.removeAllItems();
		for(Parkposition p: ppListe) {
			if (p.isFrei() == true) {
				cbxParkposition.addItem(p.getParkpositionId());
			}
		}
	}
	
	public Parkposition getSelectedParkposition()
	{
		return ppListe.get((int) cbxParkposition.getSelectedItem());
	}
	
}
